package com.huawei.appmarket.service.appdetail.view.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.View.MeasureSpec;
import android.view.ViewGroup.LayoutParams;
import android.widget.LinearLayout;

public class FixedRightLinearLayout extends LinearLayout {
    public FixedRightLinearLayout(Context context) {
        super(context);
    }

    public FixedRightLinearLayout(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
    }

    public FixedRightLinearLayout(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
    }

    protected void onMeasure(int i, int i2) {
        ॱ(i);
        super.onMeasure(i, i2);
    }

    private void ॱ(int i) {
        if (getChildCount() == 2) {
            View childAt = getChildAt(1);
            if (childAt.getVisibility() == 0) {
                int i2;
                LayoutParams layoutParams;
                View childAt2 = getChildAt(0);
                int size = MeasureSpec.getSize(i);
                childAt2.measure(0, 0);
                int measuredWidth = childAt2.getMeasuredWidth();
                childAt.measure(0, 0);
                int measuredWidth2 = childAt.getMeasuredWidth();
                LayoutParams layoutParams2 = (LinearLayout.LayoutParams) childAt2.getLayoutParams();
                LinearLayout.LayoutParams layoutParams3 = (LinearLayout.LayoutParams) childAt.getLayoutParams();
                LayoutParams layoutParams4;
                if (layoutParams2 != null) {
                    layoutParams4 = layoutParams2;
                    i2 = (0 + layoutParams2.leftMargin) + layoutParams2.rightMargin;
                    layoutParams = layoutParams4;
                } else {
                    layoutParams4 = new LinearLayout.LayoutParams(-2, -2);
                    i2 = 0;
                    layoutParams = layoutParams4;
                }
                if (layoutParams3 != null) {
                    i2 = (i2 + layoutParams3.leftMargin) + layoutParams3.rightMargin;
                }
                if (size < (measuredWidth + measuredWidth2) + i2) {
                    i2 = (size - measuredWidth2) - i2;
                    if (i2 != layoutParams.width) {
                        layoutParams.width = i2;
                        childAt2.setLayoutParams(layoutParams);
                        return;
                    }
                    return;
                }
                layoutParams.width = -2;
                childAt2.setLayoutParams(layoutParams);
            }
        }
    }
}
